package mahan.data.model;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

import org.json.JSONException;
import org.json.JSONObject;

public class CartLineItem implements KeyValuePair {
	private int productID;
	private double sellingPrice;
	private Date added;
	private double size;
	private String itemType;

	public Map<String, ?> get() {
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("pid", productID);
		map.put("sell", sellingPrice);
		map.put("add", added);
		map.put("sz", size);
		map.put("it", itemType);
		return map;
	}

	public Date getAdded() {
		return added;
	}

	public String getItemType() {
		return itemType;
	}

	public int getProductID() {
		return productID;
	}

	public double getSellingPrice() {
		return sellingPrice;
	}

	public double getSize() {
		return size;
	}

	public JSONObject json() throws JSONException {
		JSONObject json = new JSONObject();
		json.append("pid", productID);
		json.append("sell", sellingPrice);
		json.append("add", added);
		json.append("sz", size);
		json.append("it", itemType);
		return json;
	}

	public void put(Map<String, ?> map) {
		productID = (Integer) map.get("pid");
		sellingPrice = (Double) map.get("sell");
		added = (Date) map.get("add");
		size = (Float) map.get("sz");
		itemType = (String) map.get("it");
	}

	public void setAdded(Date added) {
		this.added = added;
	}

	public void setItemType(String itemType) {
		this.itemType = itemType;
	}

	public void setProductID(int productID) {
		this.productID = productID;
	}

	public void setSellingPrice(double sellingPrice) {
		this.sellingPrice = sellingPrice;
	}

	public void setSize(Double double1) {
		this.size = double1;
	}
}